//我关注的企业内容
import React, { Component } from 'react';
import {
    View,
    Text,
    Image,
    TouchableOpacity,
} from 'react-native';

import { followallStyle as styles } from '../../../../styles';
import {common_url} from "../../../util/fetch";

var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;
var height = Dimensions.get('window').height;

export default class Follow_list extends Component {
    constructor(props) {
        super(props);
    }
    render() {
        return (
            <TouchableOpacity
                style={styles.bro_all}
                onPress={() => { this.goGet('Company', this.props.company.companyId); }}
            >
                <View style={[styles.bro_left, { width: width * 0.8 }]}>
                    <Image source={
                        this.props.company.companyPicture ?
                            {uri: common_url + "uploadImg/" + this.props.company.companyPicture}
                            :require('../../../img/app/company.png')} style={styles.head} />
                    <View style={styles.bro_right}>
                        <Text style={styles.bro_text1}>
                            {this.props.company.company.companyName}
                        </Text>
                        <View style={styles.bro_bot}>
                            {this.fieldName(this.props.company.company.domains, 3)}
                        </View>
                    </View>
                </View>
            </TouchableOpacity>
        )
    }

    //经营领域
    fieldName(List, sl) {
        let arr = [];                            //用来装公司类型
        if (List != undefined) {
            let s = sl;
            let length = List.length
            if (length <= s) {
                s = length
            }
            for (let i = 0; i < s; i++) {
                arr.push(
                    <Text key={i} style={styles.bro_text2}>{List[i].field.fieldName}</Text>
                )
            }
        }
        return arr;
    }

    goGet(name, id) {
        this.props.navigation.navigate(name, { useId: id });
    }

}